﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BbsbWebService.Classes;
using BbsbWebService.Enums;

namespace BbsbWebService
{
    /// <summary>
    /// Interaction logic for NewGroup.xaml
    /// </summary>
    public partial class NewGroup : Window
    {
        public NewGroup()
        {
            InitializeComponent();
            groupTypeCmb.ItemsSource = Enum.GetNames(typeof(GroupType)).Skip(1);
            groupTypeCmb.SelectedIndex = 0;
        }

        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(nameTxt.Text))
            {
                Group = new Group();
                Group.Id = Guid.NewGuid();
                Group.Name = nameTxt.Text;
                Group.Type = (GroupType)Enum.Parse(typeof(GroupType), groupTypeCmb.Text);
            }
            this.DialogResult = true;
            this.Close();
        }

        public Group Group { get; set; }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            Group = null;
            this.Close();
        }
    }
}
